﻿@model DietPlanning.Models.UserDietModels
@{
    ViewBag.Title = "DietDetail";
    Layout = "~/Views/Shared/_LayoutUser.cshtml";
}
<script src="../../Scripts/bootstrap.js" type="text/javascript"></script>
<link href="../../css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<h2>
    @Model.Diet.First().DietName</h2>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<div class="pagination">
    <ul>
        @{
            DateTime date = new DateTime();
            foreach (var item in Model.DietDetail)
            {
                if (date != item.DateTime.Value)
                {
                    date = item.DateTime.Value;
                    <li>
                        @if (item.DateTime != null)
                        {
                            @Html.ActionLink("" + (item.DateTime.Value.DayOfYear - DateTime.Now.DayOfYear), "DietDetail", new { id = item.DietID, day = (item.DateTime.Value.DayOfYear - DateTime.Now.DayOfYear) })
                        }
                    </li>
                }
            }
        }
    </ul>
</div>
            @if (Request.IsAuthenticated)
            {
                   @Html.ActionLink("Sử dụng thực đơn này", "ViewFood",new { dishId = Model.Diet.First().DietID }) 
            }
<table class="table table-bordered table-hover table-striped">
    <tr>
        <th>
            Time
        </th>
        <th>
            Dish Type
        </th>
        <th>
            Dish Name
        </th>
        <th>
            Date Time
        </th>
        <th>
            View Detail Dish
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model.DietDetail)
    {
        if (item.DateTime.Value.DayOfYear == DateTime.Now.DayOfYear + Model.ViewDays)
        {
            if (item.Time.Equals("morning"))
            {
        <tr class="warning">
            <td>
                @Html.DisplayFor(modelItem => item.Time)
            </td>
            <td>
                <img src="/Images/Dish/@item.Dish.ImageURL/"  alt="" height="100px" width="140px" />
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Dish.DishName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Dish.DishType.DishTypeName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.DateTime)
            </td>
            <td>
                @Html.ActionLink("Xem món ăn", "ViewFood", new { dishId = item.DishID })
            </td>
        </tr>
            }
            else if (item.Time.Equals("noon"))
            {
        <tr class="error">
            <td>
                @Html.DisplayFor(modelItem => item.Time)
            </td>
            <td>
                <img src="/Images/Dish/@item.Dish.ImageURL/"  alt="" height="100px" width="140px" />
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Dish.DishName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Dish.DishType.DishTypeName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.DateTime)
            </td>
            <td>
                @Html.ActionLink("Xem món ăn", "ViewFood", new { dishId = item.DishID })
            </td>
        </tr>
            }
            else if (item.Time.Equals("evening"))
            {
        <tr class="info">
            <td>
                @Html.DisplayFor(modelItem => item.Time)
            </td>
            <td>
                <img src="/Images/Dish/@item.Dish.ImageURL/"  alt="" height="100px" width="140px" />
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Dish.DishName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Dish.DishType.DishTypeName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.DateTime)
            </td>
            <td>
                @Html.ActionLink("Xem món ăn", "ViewFood", new { dishId = item.DishID })
            </td>
        </tr>
            }
        }
    }
</table>
<div>
    @Html.ActionLink("Back to Overview", "Index")
</div>
